package cn.iocoder.yudao.module.fengdong.smartelderly.controller.admin;

import cn.iocoder.yudao.module.fengdong.smartelderly.utils.zipUtils;
import lombok.extern.log4j.Log4j2;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;

/**
 * @author zhangjiasong
 * @description: TODO
 * @date 2024/1/2 16:29
 */
@RestController
@RequestMapping("/zip")
@Validated
@Log4j2
public class zipController {
    @Resource
    zipUtils zipUtils;

    @GetMapping("/downLoad/zip")
    @CrossOrigin
    public void download(HttpServletResponse response) throws Exception {
// 指定要下载的文件的URL数组
//        String[] fileUrls = {
//                "https://dummyimage.com/400x400/f279da/79f2e6&text=admin",
//                "https://dummyimage.com/400x400/f279da/79f2e6&text=abd",
//                "https://dummyimage.com/400x400/f279da/79f2e6&text=dwqd"
//        };
        List<String> strings = new ArrayList<>();
        strings.add("https://dummyimage.com/400x400/f279da/79f2e6&text=admin");
        strings.add("https://dummyimage.com/400x400/f279da/79f2e6&text=123213");
        strings.add("https://dummyimage.com/400x400/f279da/79f2e6&text=adm214532in");
        zipUtils.downloadToLocal(strings,response);
    }


}
